/**
 * 
 */
package com.d6game.web.job;

import com.d6game.web.util.RobotUtil;

import weibo4j.Comments;
import weibo4j.Timeline;
import weibo4j.model.Status;
import weibo4j.model.StatusWapper;
import weibo4j.model.WeiboException;

/**
 * @author dell
 *
 */
public class AutoReplyJob implements Runnable{

	private String accessToken;
	public AutoReplyJob(String accessToken){
		this.accessToken = accessToken;
	}
	
	@Override
	public void run() {
		Timeline tm = new Timeline();
		tm.client.setToken(accessToken);
		Comments cm = new Comments();
		cm.client.setToken(accessToken);
		try {
			StatusWapper status = tm.getMentions();
			for(Status s : status.getStatuses()){
				String ask = s.getText();
				String answer = RobotUtil.askAndAnswer(ask);
				String id = s.getId();
				cm.createComment(answer, id);
			}
		} catch (WeiboException e) {
			e.printStackTrace();
		}
	}

}
